package source.home;



import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

public class home extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.home);
        TextView t=new TextView(this); 

        t=(TextView)findViewById(R.id.welcome); 
        String name = "welcome--->"+fetchshp("username").toString();
        t.setText(name);
        System.out.println(fetchshp("username").toString()+"value is retrieved from shared preferences" );
    }
    public void storeonclick(View button)
    {
    	   	
    	Intent intent = new Intent();
    	intent.setClass(this,store.class);
    	startActivity(intent);
    }
    public String fetchshp(String key)
    {
    	
    	//String value = null;
    	  SharedPreferences sharedPreferences = getSharedPreferences(key,MODE_PRIVATE);
    	  String value = sharedPreferences.getString(key, "not available");
    	return value;
    }
    public void logout(View button)
    {
    
    	createshp("username",null);
    	Intent intent = new Intent();
    	intent.setClass(this,welcome.class);
    	startActivity(intent);
    	
    	
    }
    public void showmessages(View button)
    {
    
    	Intent intent = new Intent();
    	intent.setClass(this,show.class);
    	startActivity(intent);
    	
    	
    }
    public void createshp(String key,String value)
    {
    	SharedPreferences sharedPreferences = getSharedPreferences(key,MODE_PRIVATE);
        SharedPreferences.Editor editor = sharedPreferences.edit();
        editor.putString(key, value);
        editor.commit();
    }   
    
}